package com.fengmi.goods.controller;


import com.fengmi.goods.MallGoods;
import com.fengmi.goods.MallGoodsSku;
import com.fengmi.goods.service.IMallGoodsService;
import com.fengmi.goods.service.IMallGoodsSkuService;
import com.fengmi.vo.CatHotGoodsVO;
import com.fengmi.vo.ResultVO;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.beans.factory.annotation.Value;
import org.springframework.cloud.context.config.annotation.RefreshScope;
import org.springframework.web.bind.annotation.PathVariable;
import org.springframework.web.bind.annotation.RequestMapping;

import org.springframework.web.bind.annotation.RestController;

import java.util.List;

/**
 * <p>
 *  前端控制器
 * </p>
 *
 * @author zhuxm
 * @since 2021-10-14
 */
@RestController
@RequestMapping("/goods")
@RefreshScope
public class MallGoodsController {
    @Value("${goods.hot.topn}")
    private Integer TOPN;
    @Autowired
    private IMallGoodsService mallGoodsService;

    @Autowired
    private IMallGoodsSkuService mallGoodsSkuService;
        @RequestMapping("findCatHotGoods")
    public List<CatHotGoodsVO>  findCatHotGoods(){
                return  mallGoodsService.findCatAndGoodsListTopn(TOPN);
        }
    @RequestMapping("findGoodsAudited")
    public List<MallGoods>  findGoodsAudited(){

        return  mallGoodsService.findGoodsSpuInfo();
    }
    //商品审核
    @RequestMapping("audit/{spuId}")
    public ResultVO audit(@PathVariable String spuId){
            return mallGoodsService.audit(spuId);
    }
    @RequestMapping("findGoodsDetail/{spuId}")
    public MallGoods findGoodsDetail(@PathVariable String spuId){

            return mallGoodsService.findGoodsDetail(spuId);
    }
    @RequestMapping("findSkuById/{skuId}")
    public MallGoodsSku findSkuById(@PathVariable String skuId){
            return mallGoodsSkuService.getById(skuId);
    }
}
